package MeteoCal.utility;

import MeteoCal.bean.ScheduleUserBean;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

/**
 *
 * @authors Guttadoro, Iommazzo, Saullo
 */
@ManagedBean
public class AutoCompleteView {
    
    @ManagedProperty("#{scheduleUserBean}")
    private ScheduleUserBean service;

    public ScheduleUserBean getService() {
        return service;
    }

    public void setService(ScheduleUserBean service) {
        this.service = service;
    }


    
   public List<Theme> completeTheme(String query){
        List<Theme> allThemes = service.getThemes();
        List<Theme> filteredThemes = new ArrayList<>();
         
        for (int i = 0; i < allThemes.size(); i++) {
            Theme skin = allThemes.get(i);
            if(skin.getName().toLowerCase().contains(query.toLowerCase())) {
                filteredThemes.add(skin);
            }
        }
         
        return filteredThemes;
    }
}
